package Web;

import IO.Buffered;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author wuhan
 * @date 2019/10/19 15:01
 */

class TransClient{
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("172.20.10.11",10005);
        BufferedReader bufr = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bufw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));

        BufferedReader bufIn = new BufferedReader(new InputStreamReader(s.getInputStream()));

        String line = null;
        while ((line=bufr.readLine())!=null){

            if ("over".equals(line))
                break;
            bufw.write(line);
            bufw.newLine();
            bufw.flush();
            String str = bufIn.readLine();
            System.out.println("server:"+str);
        }
        bufr.close();
        s.close();

    }
}

public class TextTransportDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10005);
        Socket s = ss.accept();
        String IP = s.getInetAddress().getHostAddress();
        System.out.println(IP);

        BufferedReader bufIn = new BufferedReader(new InputStreamReader(s.getInputStream()));
        BufferedWriter bufOut = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
        String line = null;
        while ((line=bufIn.readLine())!=null){

            System.out.println(line);
            bufOut.write(line.toUpperCase());
            bufOut.newLine();
            bufOut.flush();
        }
        s.close();
        ss.close();
    }
}
